package excption.work;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class test4 {
    public static void main(String[] args) {
        System.out.println("程序开始了");
        FileOutputStream fos= null;
        try {
            fos = new FileOutputStream("fos.txt");
        } catch (FileNotFoundException e) {
            System.out.println("问题1已解决");
        } finally {
            try {
                fos.write(1);
            } catch (IOException e) {
               System.out.println("问题二已解决");

            }finally {
                try {
                    fos.close();
                } catch (IOException e) {
                    System.out.println("问题三已解决");

                }
            }
        }

        try  (FileOutputStream fos1 = new FileOutputStream("fos.txt");){
           fos1.write(1);
           fos1.close();
        }  catch (IOException e) {
            System.out.println("问题三已解决");
        }finally {

        }


        System.out.println("程序结束了");
    }
}
